package com.yvdelx.cyclowomen.object;

import com.yvdelx.cyclowomen.exception.CstException;
import com.yvdelx.cyclowomen.exception.FunctionalException;

import org.simpleframework.xml.Element;

import static com.yvdelx.cyclowomen.utility.StringUtility.CST_XML_DATA_SENSATION_ELEMENT;
import static com.yvdelx.cyclowomen.utility.StringUtility.compareStrings;

/**
 * Enum object Sensation
 * Created by ydelvaux on 22/02/14.
 */
@Element(name=CST_XML_DATA_SENSATION_ELEMENT)
public enum EnumSensation {

    DRY("DRY"),
    HUMID("HUMID"),
    WET("WET"),
    LUBRICATE("LUBRICATE"),
    MENSES("MENSES");

    @Element(name=CST_XML_DATA_SENSATION_ELEMENT, type=String.class)
    private String sensation;

    EnumSensation(String sensation){
        this.sensation = sensation;
    }

    /**
     * Return the EnumSensation from its value
     * @param sensation String
     * @return EnumSensation
     */
    @SuppressWarnings("unused")
    public static EnumSensation getEnumSensation(String sensation) throws FunctionalException {
        if(compareStrings(sensation, DRY.toString())){
            return DRY;
        } else if(compareStrings(sensation, HUMID.toString())){
            return HUMID;
        } else if(compareStrings(sensation, WET.toString())){
            return WET;
        } else if(compareStrings(sensation, LUBRICATE.toString())){
            return LUBRICATE;
        } else if(compareStrings(sensation, MENSES.toString())){
            return MENSES;
        } else {
            throw new FunctionalException(CstException.CST_SENSATION_NULL);
        }
    }

    @Override
    public String toString(){
        return sensation;
    }

    /**
     * Return true if the sensation enum correspond to dry
     * @return Boolean
     */
    public boolean isDry() {
        return EnumSensation.DRY.equals(this);
    }

    /**
     * Return true if the sensation enum correspond to menses
     * @return Boolean
     */
    public boolean isMenses() {
        return EnumSensation.MENSES.equals(this);
    }
}
